package com.zcl.bean;

import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

import com.zcl.utils.NqUtil;

public class UserInfo implements Parcelable{
	private long id;
	private String userId;
	private String userName;
	private String token;
	private String tokenSecret;
	private String isDefualt;
	private Drawable userIcon;
	
	public static final String TABLE_NAME = "UserInfo";
	public static final String ID = "_id";
	public static final String USER_ID = "userId";
	public static final String USER_NAME = "userName";
	public static final String USER_TOKEN = "token";
	public static final String USER_TOKENSECRET = "tokenSecret";
	public static final String IS_DEFAULT = "isDefault";
	public static final String USER_ICON = "userIcon";
	public UserInfo()
	{
		
	}
	
	public UserInfo(String userId, String userName, String token,
			String tokenSecret, String isDefualt) {
		this.userId = userId;
		this.userName = userName;
		this.token = token;
		this.tokenSecret = tokenSecret;
		this.isDefualt = isDefualt;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public String getTokenSecret() {
		return tokenSecret;
	}
	public void setTokenSecret(String tokenSecret) {
		this.tokenSecret = tokenSecret;
	}
	public String getIsDefualt() {
		return isDefualt;
	}
	public void setIsDefualt(String isDefualt) {
		this.isDefualt = isDefualt;
	}
	public Drawable getUserIcon() {
		return userIcon;
	}
	public void setUserIcon(Drawable userIcon) {
		this.userIcon = userIcon;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(id);
		dest.writeString(userId);
		dest.writeString(userName);
		dest.writeString(token);
		dest.writeString(tokenSecret);
		dest.writeString(isDefualt);
		if (userIcon!=null) {
			dest.writeByteArray(NqUtil.drawableConvertByte(userIcon));
		}
		
	}
	
	public static final Parcelable.Creator<UserInfo> CREATOR = new Creator<UserInfo>() {

		@Override
		public UserInfo createFromParcel(Parcel source) {
			UserInfo info = new UserInfo();
			info.id = source.readLong();
			info.userId = source.readString();
			info.userName = source.readString();
			info.token = source.readString();
			info.tokenSecret = source.readString();
			info.isDefualt = source.readString();
			byte[] byteIcon = new byte[1024];
			source.readByteArray(byteIcon);
			if (byteIcon!=null && byteIcon.length>0) {
				info.setUserIcon(NqUtil.byteConvertDrawable(byteIcon));
			}
			return null;
		}

		@Override
		public UserInfo[] newArray(int size) {
			return new UserInfo[size];
		}
		
	};
}
